<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page import="org.codehaus.groovy.grails.commons.ConfigurationHolder" %>
<%@ page import="net.tribal.comic.entities.User" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="title.user.edit.profile.nav"/></title>
    </head>
    
    <body>
    	<div class="navButtonsTop rounded-corners">
			<h1 class="title"><g:message code="title.user.edit.profile" args="[userInstance.alias]"/></h1>
		</div>
	
		<g:form action="update">
			<div class="element rounded-corners">
		        <g:hasErrors bean="${userInstance}">
		        	<div class="rounded-corners errors"><g:renderErrors bean="${userInstance}" as="list" /></div>
		        </g:hasErrors>
        	
				<div class="tableCreate rounded-corners">
			    	<table>
	        			<tbody>
	    			    	<tr>
	                        	<td class="name">
	                                <label for="alias"><g:message code="default.label.alias"/>:</label>
	                            </td>
	                            <td colspan="5" class="requiredField value ${hasErrors(bean: userInstance, field: 'alias', 'errors')}">
	                                <g:textField name="alias" value="${fieldValue(bean: userInstance, field: 'alias')}" />
	                            </td>
	                        </tr>
	    			
	            			<tr>
			                	<td class="name">
			                    	<label for="name"><g:message code="default.label.name"/>:</label>
			                    </td>
	                            <td colspan="2" class="requiredField value ${hasErrors(bean: userInstance, field: 'name', 'errors')}">
	                                <g:textField name="name" class="focus" value="${fieldValue(bean: userInstance, field: 'name')}" />
	                            </td>
	                            <td class="name">
	                                <label for="lastName"><g:message code="default.label.lastName"/>:</label>
	                            </td>
	                            <td colspan="2" class="requiredField value ${hasErrors(bean: userInstance, field: 'lastName', 'errors')}">
	                                <g:textField name="lastName" value="${fieldValue(bean: userInstance, field: 'lastName')}" />
	                            </td>
	                        </tr>
	                        
	                        <tr>
	                            <td class="name">
	                                <label for="gender"><g:message code="default.label.gender"/>:</label>
	                            </td>
	                            <td colspan="2" class="value ${hasErrors(bean: userInstance, field: 'gender', 'errors')}">
	                                <g:select from="${ConfigurationHolder.config.comics.gender}" name="gender" value="${userInstance?.gender}" valueMessagePrefix="defaulf.select.gender"/>
	                            </td>
	                            <td class="name">
	                                <label for="birthDate"><g:message code="default.label.birthDate"/>:</label>
	                            </td>
	                            <td colspan="2"  class="value ${hasErrors(bean: userInstance, field: 'birthDate', 'errors')}">
	                                <g:datePicker name="birthDate" value="${userInstance?.birthDate}" precision="day" />
	                            </td>
							</tr>
	                        
	                        <tr>
	                        	<td class="name">
	                                <label for="email"><g:message code="default.label.email"/>:</label>
	                            </td>
	                            <td colspan="5" class="requiredField value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
	                                <g:textField name="email" size="50" maxlength="50" value="${fieldValue(bean: userInstance, field: 'email')}" />
	                            </td>
	                        </tr>
	                        
							<tr>
	                            <td class="name">
	                                <label for="country"><g:message code="default.label.country"/>:</label>
	                            </td>
	                            <td colspan="5" class="value ${hasErrors(bean: userInstance, field: 'country', 'errors')}">
	                    			<g:countrySelect name="country" default="${userInstance.country}" value="${fieldValue(bean:userInstance,field:'country')}"/>
	                    		</td>
	                        </tr>
	                        
	                        <tr>
	                            <td class="name">
	                            	<usr:isAdmin>
                                		<label for="disabled"><g:message code="default.label.disabled"/>:</label>
                                	</usr:isAdmin>
	                            </td>
	                            <td class="value ${hasErrors(bean: userInstance, field: 'disabled', 'errors')}">
	                            	<usr:isAdmin>
	                                	<g:checkBox name="disabled" value="${userInstance?.disabled}" />
	                                </usr:isAdmin>
	                            </td>
	                            <td class="name">
	                                <label for="commentable"><g:message code="default.label.commentable"/>:</label>
	                            </td>
	                            <td class="value ${hasErrors(bean: userInstance, field: 'commentable', 'errors')}">
	                                <g:checkBox name="commentable" value="${userInstance?.commentable}" />
	                            </td>
	                            <td class="name">
	                                <label for="rateable"><g:message code="default.label.rateable"/>:</label>
	                            </td>
	                            <td class="value ${hasErrors(bean: userInstance, field: 'rateable', 'errors')}">
	                                <g:checkBox name="rateable" value="${userInstance?.rateable}" />
	                        	</td>
	                		</tr>
	        			</tbody>
			        </table>
		        </div>
		    </div>

			<div class="navButtons rounded-corners">
	    		<div class="left">
		        	<g:actionSubmit class="save" action="updateProfile" value="${message(code:'default.button.update')}" />
		        </div>
		        <div class="right">
		        	<g:actionSubmit class="show" action="show" value="${message(code:'default.button.back')}" />
		        </div>
	    	</div>		    
	    	
			<g:hiddenField name="id" value="${userInstance?.id}" />
			<g:hiddenField name="version" value="${userInstance?.version}" />
		</g:form>

	</body>
</html>
